package cn.bonoon.services.plugins;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.bonoon.core.plugins.VacationService;
import cn.bonoon.entities.calendars.VacationEntity;
import cn.bonoon.kernel.support.services.AbstractService;
import cn.bonoon.util.VacationInfo;

@Service
@Transactional(readOnly = true)
public class VacationServiceImpl extends AbstractService<VacationEntity> implements VacationService{

	@Override
	@Transactional(readOnly = true)
	public VacationInfo yearVacation(int year, long type, long user) {
		VacationEntity ve = get(year, type, user);
		if(null != ve) return new VacationInfo(ve);
		return null;
	}

	@Override
	public VacationEntity get(int year, long type, long user) {
		String ql = "from VacationEntity x where x.year=?1 and x.ownerId=?2 and x.ext=?3";
		return __first(domainClass, ql, year, user, type);
	}

}
